/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ssp.event;

import java.util.ArrayList;
import java.util.List;
import ssp.net.NWcomponent;
import ssp.net.NWcomponentManager;
import ssp.topology.Node;

/**
 * ネットワークマップを更新する
 * @author yamazaki
 */
public class NetworkMapUpdateEvent extends Event {
    
    private final double t = 0;
    
    public NetworkMapUpdateEvent(double eventTime) {
        super(eventTime);
    }

    @Override
    public void fire() {
        for(NWcomponent nwComponent : NWcomponentManager.getINSTANCE().getNWcomponentList()) {
            List<Node> neighbors = new ArrayList<Node>(nwComponent.getNeighborNWcomponents());
            for(int i=0 ; i< neighbors.size() ; i++) {
                for(int j=i ; j<neighbors.size() ; j++) {
                    nwComponent.updateNWmap(neighbors.get(i), neighbors.get(j), this.getEventTime());
                }
            }
        }
        
        if(t >0) {
            EventQueue eventQueue = EventQueue.getINSTANCE();
            eventQueue.addEvent(new NetworkMapUpdateEvent(eventQueue.getCurrentTime() + t));
        }
    }
    
}
